package git.bankview.wl.common;

import java.util.*;
import java.text.*;
import java.sql.*;

import laya.semi.process.*;

import git.bankview.sl.db.*;

import org.apache.log4j.Logger;

public class SqlDateFormatter
	implements IGenericClassActivity
{
	private static Logger log = Logger.getLogger(SqlDateFormatter.class);

	public void execute(IProcessContext oCtx)
		throws Exception
	{
		String[] vParam = oCtx.getActivityParameter().split(":");
		String fmt = vParam[0];
		SimpleDateFormat sdf = new SimpleDateFormat(fmt);
		
		for (int i = 1; i < vParam.length; ++i)
		{
			String[] vDestSrc = vParam[i].split("=");
			java.util.Date oVal = (java.util.Date)oCtx.getField(vDestSrc[1]);
			String oSrc = (null == oVal ? null : sdf.format(oVal));
			oCtx.setField(vDestSrc[0], oSrc);
		}
	}
}
